<template>
    <div class="app-container">
        <div class="contentBox">
            <div class="searchBox">
                <el-form :model="queryParams" ref="queryRef" :inline="true" @submit.prevent>
                    <el-form-item prop="name" style="margin: 0 6px 0 0;">
                        <el-input
                            class="inputBox"
                            v-model="queryParams.name"
                            placeholder="请输入名称"
                            clearable
                            @keyup.enter="handleQuery"
                        />
                    </el-form-item>
                    <el-form-item style="margin: 0 6px 0 0;">
                        <el-button class="normalFormBg searchBtn" icon="Search" @click="handleQuery"></el-button>
                        <el-button class="normalFormBg searchBtn" icon="Refresh" @click="resetQuery"></el-button>
                    </el-form-item>
                </el-form>
            </div>
            <el-row :gutter="10" style="margin: 16px 0;">
                <el-col :span="1.5">
                    <div class="normalBtn pageFlex pageFlexCenter" @click="handleAdd">
                        <img src="@/assets/images/plus.png" class="normalBtn_icon">
                        <div class="normalBtn_text">新增</div>
                    </div>
                </el-col>
            </el-row>
            <el-table 
                v-loading="loading"
                :data="dataList"
                border>
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column prop="date" label="日期" width="100" :show-overflow-tooltip="true" fixed="left"></el-table-column>
                <el-table-column prop="creditCode" label="物料编码" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="名称" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="货位号" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="规格" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="品牌型号" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="单位" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="入库数量" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="单价" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="总金额" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="入库人" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="入库凭证号" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="类别" width="150"></el-table-column>
                <el-table-column prop="creditCode" label="供货商" width="150"></el-table-column>
		        <template #empty>
                    <el-empty description="暂无数据" style="color: var(--el-color-primary);"/>
                </template>
            </el-table>
            <div class="pageFlex pageAlignCenter pageSpaceBetween" style="margin-top: 20px;">
                <div class="totalText">共计 {{total}} 条</div>
                <el-pagination background layout="prev, pager, next" :total="total" :current-page="queryParams.pageNum" :page-size="queryParams.pageSize" @current-change="handleCurrentChange"/>
            </div>
        </div>
        <el-drawer v-model="modalShow" direction="rtl" size="600" :title="modalTitle">
            <div class="modalBox">
                <div class="modalBoxContent">
                    <el-form
                        ref="formRef"
                        class="formContent"
                        label-width="80"
                        :model="form"
                        :rules="rules"
                        :disabled="modalTitle === '燃气卡详情'"
                    >
                        <div class="formContentTop pageFlex pageAlignCenter">
                            <div class="line"></div>
                            <div class="title">燃气卡信息</div>
                        </div>
                        <div class="formContentCenter bgFF">
                            <el-form-item label="卡名"></el-form-item>
                            <el-form-item label="卡号"></el-form-item>
                        </div>
                    </el-form>
                </div>
                <div class="lineBox" v-if="modalTitle !== '燃气卡详情'"></div>
                <div class="bottomBox pageFlex pageFlexCenter" v-if="modalTitle !== '燃气卡详情'">
                <el-button type="primary" :loading="submitLoading" @click="submitNow">确认提交</el-button>
                </div>
                <el-button type="primary" :loading="formLoading" class="modalLoadingBox" v-if="formLoading">加载数据中</el-button>
            </div>
        </el-drawer>
    </div>
</template>
<script setup>
import { onMounted } from 'vue';
const { proxy } = getCurrentInstance();
// -------------------------------------弹窗-------------------------------------
const modalShow = ref(false);
const modalTitle = ref('');
const submitLoading = ref(false);
const formLoading = ref(false);
const form = ref({});
const rules = ref({});
function handleModalShow(name){
    modalShow.value = true;
    modalTitle.value = name
}
function submitNow(){

}
// -------------------------------------新增-------------------------------------
function handleAdd(){
    handleModalShow('新增燃气卡');
}
// -------------------------------------查询-------------------------------------
onMounted(()=>{
    getList();
})
const queryParams = ref({
    pageNum: 1,
    pageSize: 10,
    name: ''
})
const loading = ref(false);
const total = ref(0);
const dataList = ref([]);
function handleQuery(){
    queryParams.value.pageNum = 1;
    getList();
}
function resetQuery(){
    proxy.resetForm("queryRef");
    handleQuery();
}
function getList(){
    loading.value = true;
    setTimeout(()=>{
        dataList.value =  [
            {
                id: 1,
                name: '企业1'
            }
        ]
        loading.value = false;
    }, 1000)
}
function handleCurrentChange(e){
    console.log(e)
}
</script>
<style lang='scss' scoped>
@import "@/assets/styles/public.scss";
:deep(.el-input){
    .el-input__wrapper{
        background-color: $formBgSet;
        box-shadow: none;
    }
}
.app-container{
    width: 100%;
    min-height: calc(100vh - 66px);
    background: #F8F8F9;
    .contentBox{
        width: 100%;
        min-height: calc(100vh - $navBarHeight - 40px);
        background-color: #FFFFFF;
        border-radius: 5px;
        box-sizing: border-box;
        padding: 12px;
        .searchBtn{
            width: 32px;
            height: 32px;
            font-size: 12px;
            padding: 0;
            border: none;
            margin: 0 6px 0 0px;
        }
        .btnSetBox{
            padding: 0 10px;
            box-sizing: border-box;
            border-right: 1px solid $borderColor;
            cursor: pointer;
            .text{
                height: 16px;
                line-height: 16px;
                color: var(--el-color-primary);
            }
            .img{
                width: 16px;
                height: 16px;
                margin-right: 2px;
            }
            &:last-child{
                border-right: none;
            }
        }
        .totalText{
            height: 22px;
            font-weight: 400;
            font-size: 14px;
            color: #1D2129;
            line-height: 22px;
        }
    }
}
:deep(.el-drawer){
  .el-drawer__header{
    margin: 0;
    padding-bottom: 20px;
  }
  .el-drawer__body{
    padding: 0;
  }
}
</style>

